package com.sbp.message.api.common;

import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.regex.Pattern;

/**
 * Created by wangmin on 2018/5/4.
 */
public abstract class CommonUtils {
    // 最大尝试次数
    public static final int MAX_RETIES = 1024;


    private static final Pattern delimiterPattern = Pattern.compile(",");
    public static ArrayList<String> splitByComma(String str) {
        ArrayList<String> result = new ArrayList<>();

        String[] array = delimiterPattern.split(str);
        for (String element : array) {
            element = element.trim();
            if (StringUtils.isEmpty(element)) {
                continue;
            }
            result.add(element);
        }

        return result;
    }

    public static boolean isBusinessFailedConsumer(String acknowledgeDescribeInDB) {
        return acknowledgeDescribeInDB.indexOf(0) == '!';
    }
}
